﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace QLTV
{
    class ketnoi
    {
        public SqlConnection taokn()
        {
            return new SqlConnection(@"Data Source=SCD090508\;Initial Catalog=quanlythuvien;Persist Security Info=True;User ID=sa;Password=1234");
        }
        //load dữ liệu từ bảng
        public DataTable taobang(string sql)
        {
            SqlConnection cn = taokn();
            SqlDataAdapter da = new SqlDataAdapter(sql, cn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        // cập nhật dữ liệu
        public void ExecuteNonQuery(string sql)
        {
            SqlConnection cn = taokn();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.ExecuteNonQuery();
            cn.Close();
        }
    }
}
